package com.lefeng.cockpit.admin.api.v1.datax;

import com.lefeng.cockpit.datax.core.biz.model.HandleCallbackParam;
import com.lefeng.cockpit.datax.core.biz.model.HandleProcessCallbackParam;
import com.lefeng.cockpit.datax.core.biz.model.RegistryParam;
import com.lefeng.cockpit.datax.core.biz.model.ReturnT;
import com.lefeng.cockpit.datax.service.impl.RegistryExecutorImpl;
import com.lefeng.cockpit.datax.util.JacksonUtil;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author weifw
 */
@RestController
@RequestMapping("/executor/api")
@Api(tags = "datax-executor注册")
public class RegistryController {

    @Resource
    private RegistryExecutorImpl registryExecutor;

    @PostMapping("/registry")
    public ReturnT<String> registry(@RequestBody RegistryParam registryParam) {
        return registryExecutor.registry(registryParam);
    }

    @PostMapping("/callback")
    public ReturnT<String> callback(@RequestBody List<HandleCallbackParam> registryParam) {
        return registryExecutor.callback(registryParam);
    }

    @PostMapping("/processCallback")
    public ReturnT<String> processCallback(@RequestBody List<HandleProcessCallbackParam> handleProcessCallbackParams) {
        return registryExecutor.processCallback(handleProcessCallbackParams);
    }

    @PostMapping("/registryRemove")
    public ReturnT<String> registryRemove(@RequestBody RegistryParam registryParam) {
        return registryExecutor.registryRemove(registryParam);
    }

}